from datetime import datetime, timezone
from typing import Dict, Any
from app.config.logging_config import get_logger

# 获取通用模块的日志记录器
logger = get_logger(__name__)

# 获取当前UTC时间
def get_current_time() -> datetime:
    """获取当前UTC时间"""
    return datetime.now(timezone.utc)

# 标准化响应格式
def create_response(data: Any = None, success: bool = True, message: str = "") -> Dict:
    """创建标准化的API响应"""
    return {
        "success": success,
        "message": message,
        "data": data,
        "timestamp": get_current_time().isoformat(),
    }

# 记录请求信息
def log_request(request_method: str, request_path: str, request_data: Any = None) -> None:
    """记录API请求信息"""
    logger.info(
        f"Request: {request_method} {request_path} - Data: {request_data if request_data else 'None'}"
    )

# 记录响应信息
def log_response(request_path: str, response_status: int, response_data: Any = None) -> None:
    """记录API响应信息"""
    logger.info(
        f"Response: {request_path} - Status: {response_status} - Data: {response_data if response_data else 'None'}"
    )